global $wgLang;
foreach ( $this->getTrace() as $frame ) {
- if ( isset( $frame['class'] ) && $frame['class'] === 'LocalisationCache' ) {
+ if ( isset( $frame['class'] ) && $frame['class'] === LocalisationCache::class ) {
return false;
}
}
return $wgLang instanceof Language;
}
- /**
- * Run hook to allow extensions to modify the text of the exception
- *
- * @param string $name Class name of the exception
- * @param array $args Arguments to pass to the callback functions
- * @return string|null String to output or null if any hook has been called
- */
- public function runHooks( $name, $args = [] ) {
- return MWExceptionRenderer::runHooks( $this, $name, $args );
- }
-
/**
* Get a message from i18n
*
"</p>\n";
} else {
$logId = WebRequest::getRequestId();
- $type = get_class( $this );
- return "<div class=\"errorbox\">" .
- '[' . $logId . '] ' .
- gmdate( 'Y-m-d H:i:s' ) . ": " .
- $this->msg( "internalerror-fatal-exception",
- "Fatal exception of type $1",
- $type,
- $logId,
- MWExceptionHandler::getURL( $this )
- ) . "</div>\n" .
+ $type = static::class;
+ return Html::errorBox(
+ htmlspecialchars(
+ '[' . $logId . '] ' .
+ gmdate( 'Y-m-d H:i:s' ) . ": " .
+ $this->msg( "internalerror-fatal-exception",
+ "Fatal exception of type $1",
+ $type,
+ $logId,
+ MWExceptionHandler::getURL( $this )
+ )
+ ) ) .
"<!-- Set \$wgShowExceptionDetails = true; " .
"at the bottom of LocalSettings.php to show detailed " .
"debugging information. -->";
if ( $this->useOutputPage() ) {
$wgOut->prepareErrorPage( $this->getPageTitle() );
- $hookResult = $this->runHooks( get_class( $this ) );
- if ( $hookResult ) {
- $wgOut->addHTML( $hookResult );
- } else {
- $wgOut->addHTML( $this->getHTML() );
- }
+ $wgOut->addHTML( $this->getHTML() );
$wgOut->output();
} else {
'<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
"</head><body>\n";
- $hookResult = $this->runHooks( get_class( $this ) . 'Raw' );
- if ( $hookResult ) {
- echo $hookResult;
- } else {
- echo $this->getHTML();
- }
+ echo $this->getHTML();
echo "</body></html>\n";
}
* It will be either HTML or plain text based on isCommandLine().
*/
public function report() {
- MWExceptionRenderer::output( $this, MWExceptionRenderer::AS_PRETTY );
+ global $wgMimeType;
+
+ if ( defined( 'MW_API' ) ) {
+ // Unhandled API exception, we can't be sure that format printer is alive
+ self::header( 'MediaWiki-API-Error: internal_api_error_' . static::class );
+ wfHttpError( 500, 'Internal Server Error', $this->getText() );
+ } elseif ( self::isCommandLine() ) {
+ $message = $this->getText();
+ // T17602: STDERR may not be available
+ if ( defined( 'STDERR' ) ) {
+ fwrite( STDERR, $message );
+ } else {
+ echo $message;
+ }
+ } else {
+ self::statusHeader( 500 );
+ self::header( "Content-Type: $wgMimeType; charset=utf-8" );
+
+ $this->reportHTML();
+ }
}
/**